#!/usr/bin/env python3
import sys
import os
sys.path.append(os.path.dirname(os.path.abspath(__file__)))

from sqlalchemy import text
from app.db.database import engine

def update_product_detail():
    try:
        with engine.connect() as conn:
            print("更新 product_details 表结构...")
            
            # 添加新字段
            conn.execute(text("""
                ALTER TABLE product_details
                ADD COLUMN specifications TEXT NULL
            """))
            
            conn.execute(text("""
                ALTER TABLE product_details
                ADD COLUMN features TEXT NULL
            """))
            
            conn.commit()
            print("✅ product_details 表更新成功！")
            
    except Exception as e:
        print(f"❌ 更新 product_details 表时出错: {e}")
        return False
    return True

if __name__ == "__main__":
    print("开始更新 product_details 表...")
    if update_product_detail():
        print("✅ 数据库更新成功！")
    else:
        print("❌ 数据库更新失败！") 